/*
 * Copyright (C) 2010 mAPPn.Inc
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.mol.market.ui_v4;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.view.ViewPager;

import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuItem;
import com.mol.market.R;
import com.mol.market.common.util.Utils;
import com.mol.market.demo.widget.BaseFragmentActivity;
import com.mol.market.fanli.ui.MakeMoneyActivity;
import com.mol.market.ui.PersonalAccountFragment;
import com.mol.market.ui.SearchActivity;

/**
 * 达人推荐页
 * 
 * @author andrew.wang
 * @date 2011-12-19
 * @since Version 0.9.0
 * 
 */
public class MasterTabActivity extends BaseFragmentActivity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        setContentView(R.layout.demo_activity_home);
        initTabs();
    }

    private void initTabs() {

        ActionBar mActionBar = getSupportActionBar();
        mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
        mActionBar.setDisplayHomeAsUpEnabled(true);
        mActionBar.setHomeButtonEnabled(true);
        mActionBar.setDisplayShowTitleEnabled(true);
        mActionBar.setTitle(R.string.sort_expert_recommend);

        ViewPager pager = (ViewPager) findViewById(R.id.viewpager);

        PagerAdapter adapter = new PagerAdapter(getSupportFragmentManager(), this, getApplicationContext(), pager, mActionBar);

        ActionBar.Tab tab1 = mActionBar.newTab().setText(R.string.recommendation_all);
        ActionBar.Tab tab2 = mActionBar.newTab().setText(R.string.recommendation_follow);

        adapter.addTab(tab1, MasterRecommendListFragment.class, tab1.getText(), null);
        adapter.addTab(tab2, FollowedRecommendFragment.class, tab2.getText(), null);

        pager.setAdapter(adapter);
    }

//    @Override
//    public boolean onCreateOptionsMenu(Menu menu) {
//        getSupportMenuInflater().inflate(R.menu.home_menu, menu);
//        return super.onCreateOptionsMenu(menu);
//    }
//
//    @Override
//    public boolean onOptionsItemSelected(MenuItem item) {
//        switch (item.getItemId()) {
//            case android.R.id.home: {
//                onBackPressed();
//                return true;
//            }
//            case R.id.menu_search: {
//                Utils.jumpToPage(this, SearchActivity.class, false);
//                return true;
//            }
//            case R.id.menu_rebate: {
//                Intent i = new Intent(getApplicationContext(), MakeMoneyActivity.class);
//                startActivity(i);
//                return true;
//            }
//            case R.id.menu_manager: {
//
//                Intent i = new Intent(getApplicationContext(), AppManagerActivity.class);
//                startActivity(i);
//                return true;
//            }
//            case R.id.menu_account: {
//
//                Intent i = new Intent(getApplicationContext(), PersonalAccountActivity.class);
//                startActivity(i);
//                return true;
//            }
//        }
//        return super.onOptionsItemSelected(item);
//    }

}
